//
//  HHToggleSample.swift
//  HHSwiftuiPractice
//
//  Created by YL-Hong on 2023/10/8.
// Toggle也是经常在开发中使用到的一个组件，比如我们在app中设定了黑白模式，开就是黑模式，关就是白模式

import SwiftUI

struct HHToggleSample: View {
    @State var toggleIsOn:Bool = false
    @State var isShuffling: Bool = false
    @State var isRepeating: Bool = false
    @State var isEnhanced: Bool = false
    var body: some View {
        VStack{
            
            //SwitchToggleStyle(tint: .purple) 来修改Toggle的颜色
            Toggle(toggleIsOn ? "White" : "Dark", isOn: $toggleIsOn)
                .toggleStyle(SwitchToggleStyle(tint: .purple))
            
            Toggle(isOn: $isShuffling) {
                           Label("Shuffle", systemImage: "shuffle")
                       }

            Toggle(isOn: $isRepeating) {
                           Label("Repeat", systemImage: "repeat")
                       }
            
            Toggle("Enhance Sound", isOn: $isEnhanced)
                           .toggleStyle(.button)
                           .padding()
            
   
        }.padding(.horizontal,100)
    
    }
}

struct HHToggleSample_Previews: PreviewProvider {
    static var previews: some View {
        HHToggleSample()
    }
}
